# app/model_loader.py
import logging
from app.services.prediction_service import load_models

preloaded_models = None

def preload_models():
    global preloaded_models
    try:
        logging.info("Starting to preload models...")
        preloaded_models = load_models()
        if preloaded_models:
            logging.info("All models preloaded successfully.")
        else:
            logging.warning("Failed to preload models, preloaded_models is None.")
    except Exception as e:
        logging.error(f"Failed to preload models: {str(e)}", exc_info=True)